{% extends "base.html" %}

{% block title %}Status page{% endblock %}

{% block content %}
    <article id="main" class="markdown-section">
	<h1>Status</h1>
        <h3 id="groupsstatus">📚 Groups status</h3>
        <table id="table" class="table" style="display:table; table-layout:auto; width:100%">
          <thead>
            <tr>
                <th style="width:15%"><center>Group</center></th>
                <th style="width:20%"><center>Page title</center></th>
                <th style="width:5%"><center>Server status</center></th>
                <th style="width:10%"><center>Last seen</center></th>
                <th style="width:45%"><center>Location</center></th>
                <th style="width:5%"><center>Screen</center></th>
            </tr>
          </thead>
          <tbody>
            {% for entry in data %}
                {% for location in entry['locations'] %}
                <tr><td> <a href="/group/{{entry['name']}}"> {{entry['name']}} </td>
                <td> {{location['title'] }} </td>
                {% if location['available'] is true %}
                <td> <center> ⬆️</center> </td>
                {% else %}
                <td> <center>⬇️</center> </td>
                {% endif %}
                <td> {{location['lastscrape'].split(' ')[0]}} </td>
                <td> {{location['fqdn']}} </td>
                {% if 'screen' in location %}
                <td><a href="{{ location['screen'] }}" rel="noopener noreferrer" target="_blank">Screen</a></td>
                {% else %}
                <td> </td>
                {% endif %}
                </tr>
                {% endfor %}
            {% endfor %}
          <tbody>
        </table>
        <h3 id="marketsstatus">📚 Markets status</h3>
        <table id="table" class="table" style="display:table; table-layout:auto; width:100%">
          <thead>
            <tr>
                <th style="width:15%"><center>Markets</center></th>
                <th style="width:20%"><center>Page title</center></th>
                <th style="width:5%"><center>Server status</center></th>
                <th style="width:10%"><center>Last seen</center></th>
                <th style="width:45%"><center>Location</center></th>
                <th style="width:5%"><center>Screen</center></th>
            </tr>
          </thead>
          <tbody>
            {% for entry in markets %}
                {% for location in entry['locations'] %}
                <tr><td> <a href="/market/{{entry['name']}}"> {{entry['name']}} </td>
                <td> {{location['title'] }} </td>
                {% if location['available'] is true %}
                <td> <center> ⬆️</center> </td>
                {% else %}
                <td> <center>⬇️</center> </td>
                {% endif %}
                <td> {{location['lastscrape'].split(' ')[0]}} </td>
                <td> {{location['fqdn']}} </td>
                {% if 'screen' in location %}
                <td><a href="{{ location['screen'] }}" rel="noopener noreferrer" target="_blank"">Screen</a></td>
                {% else %}
                <td> </td>
                {% endif %}
                </tr>
                {% endfor %}
            {% endfor %}
          <tbody>
        </table>
    </article>
{% endblock %}
